CC := $(CROSS_COMPILE)gcc

log:=thirdparty/log/log.h thirdparty/log/log.c
log_test: test/log_test.c $(log)
	-$(CC) -o $@ $^ -Ithirdparty
	-./$@
	-rm ./$@

cjson:=thirdparty/cJSON/cJSON.h thirdparty/cJSON/cJSON.c

cjson_test: test/cjson_test.c $(cjson)
	-$(CC) -o $@ $^ -Ithirdparty
	-./$@
	-rm ./$@

test/mqtt_test: test/mqtt_test.c $(log)
	-$(CC) -o $@ $^ -Ithirdparty -lpaho-mqtt3c
	-sudo ./$@
	-rm ./$@

app_common:=app/app_common.h app/app_common.c
app_common_test: test/app_common_test.c $(app_common)
	-$(CC) -o $@ $^ -Iapp
	-./$@
	-rm ./$@

app_buff:=app/app_buffer.h app/app_buffer.c
app_buffer_test: test/app_buffer_test.c $(app_buff) $(log)
	-$(CC) -o $@ $^ -Ithirdparty -Iapp
	-./$@
	 -rm ./$@

app_message:=app/app_message.h app/app_message.c
test/app_message_test: test/app_message_test.c $(log) $(app_message) $(cjson)
	-$(CC) -o $@ $^ -Ithirdparty
	-./$@
	-rm ./$@

app_mqtt:=app/app_mqtt.h app/app_mqtt.c
test/app_mqtt_test: test/app_mqtt_test.c $(log) $(app_mqtt) $(cjson)
	-$(CC) -o $@ $^ -Ithirdparty -ggdb -lpaho-mqtt3c
# 	-./$@
# 	-rm ./$@